tools/ocaml/xenstored: do permission checks on xenstore root
authorEdwin Török <edvin.torok@citrix.com>
Tue, 15 Dec 2020 12:33:43 +0000 (13:33 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 15 Dec 2020 12:33:43 +0000 (13:33 +0100)
commitfeeafa007b804cdf2406c50a6515ee0a217d3438
treead69a5d30af70c9ef79415b3e4e1d2b659a74b33
parent8e0fe4fe5fd89d80a362d8a9a46726aded3b49c4
tools/ocaml/xenstored: do permission checks on xenstore root

This was lacking in a disappointing number of places.

The xenstore root node is treated differently from all other nodes, because it
doesn't have a parent, and mutation requires changing the parent.

Unfortunately this lead to open-coding the special case for root into every
single xenstore operation, and out of all the xenstore operations only read
did a permission check when handling the root node.

This means that an unprivileged guest can:

 * xenstore-chmod / to its liking and subsequently write new arbitrary nodes
   there (subject to quota)
 * xenstore-rm -r / deletes almost the entire xenstore tree (xenopsd quickly
   refills some, but you are left with a broken system)
 * DIRECTORY on / lists all children when called through python
   bindings (xenstore-ls stops at /local because it tries to list recursively)
 * get-perms on / works too, but that is just a minor information leak

Add the missing permission checks, but this should really be refactored to do
the root handling and permission checks on the node only once from a single
function, instead of getting it wrong nearly everywhere.

This is XSA-353.

Signed-off-by: Edwin Török <edvin.torok@citrix.com>
Acked-by: Christian Lindig <christian.lindig@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
tools/ocaml/xenstored/store.ml